using Godot;
using System;

public class HoverText : Node2D
{
    RichTextLabel richTextLabel;
    AnimationPlayer ap;
    public override void _Ready()
    {
        richTextLabel = GetNode<RichTextLabel>("RichTextLabel");
        ap = GetNode<AnimationPlayer>("AnimationPlayer");
    }
    public void SetText(int x,int y,String text,bool rand=true)
    {
        Vector2 os = new Vector2(0,0);
        if(rand)
        {
            os.x=new Random().Next(16);
            os.y=new Random().Next(16);
            if(new Random().Next(1) == 0)os.x=-os.x;
            if(new Random().Next(1) == 0)os.y=-os.y;
        }
        richTextLabel.BbcodeText = text;
        Position = new Vector2(x,y)+os;
        ap.Play("play");
    }
    public void TimeOut(String anim)
    {
        QueueFree();
    }
}
